package com.example.simplestudy.clock;

import androidx.appcompat.app.AppCompatActivity;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.simplestudy.R;

public class ClockActivity extends AppCompatActivity {

    private ImageView clockHand;
    private TextView timeText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_clock);
        clockHand = findViewById(R.id.clock_hand);
        timeText = findViewById(R.id.time_text);

        startRotationClockAnimation();
    }

    private void startRotationClockAnimation() {
        ObjectAnimator rotationAnimator = ObjectAnimator.ofFloat(clockHand, "rotation", 0f, 360f);
        rotationAnimator.setDuration(1000);
        rotationAnimator.setRepeatCount(ObjectAnimator.INFINITE);

        ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(timeText, "scaleX", 1f, 1.2f, 1f);
        scaleXAnimator.setDuration(1000);
        scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);

        ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(timeText, "scaleY", 1f, 1.2f, 1f);
        scaleYAnimator.setDuration(1000);
        scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(rotationAnimator, scaleXAnimator, scaleYAnimator);
        animatorSet.start();

      /*  // 设置旋转动画
        RotateAnimation rotateAnimation = new RotateAnimation(0, 360,
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(10000);
        rotateAnimation.setRepeatCount(Animation.INFINITE);
        clockHand.startAnimation(rotateAnimation);*/
    }
}